package com.ruoyi.jiajia.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JiajiaJuBao;
import com.ruoyi.system.service.IJiajiaJuBaoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 举报Controller
 * 
 * @author knd
 * @date 2021-10-14
 */
@Controller
@RequestMapping("/jiajia/jiajiajubao")
public class JiajiaJuBaoController extends BaseController
{
    private String prefix = "jiajia/jiajiajubao";

    @Autowired
    private IJiajiaJuBaoService jiajiaJuBaoService;

    @RequiresPermissions("jiajia:jiajiajubao:view")
    @GetMapping()
    public String jiajiajubao()
    {
        return prefix + "/jiajiajubao";
    }

    /**
     * 查询举报列表
     */
    @RequiresPermissions("jiajia:jiajiajubao:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JiajiaJuBao jiajiaJuBao)
    {
        startPage();
        List<JiajiaJuBao> list = jiajiaJuBaoService.selectJiajiaJuBaoList(jiajiaJuBao);
        return getDataTable(list);
    }

    /**
     * 导出举报列表
     */
    @RequiresPermissions("jiajia:jiajiajubao:export")
    @Log(title = "举报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JiajiaJuBao jiajiaJuBao)
    {
        List<JiajiaJuBao> list = jiajiaJuBaoService.selectJiajiaJuBaoList(jiajiaJuBao);
        ExcelUtil<JiajiaJuBao> util = new ExcelUtil<JiajiaJuBao>(JiajiaJuBao.class);
        return util.exportExcel(list, "举报数据");
    }

    /**
     * 新增举报
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存举报
     */
    @RequiresPermissions("jiajia:jiajiajubao:add")
    @Log(title = "举报", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JiajiaJuBao jiajiaJuBao)
    {
        return toAjax(jiajiaJuBaoService.insertJiajiaJuBao(jiajiaJuBao));
    }

    /**
     * 修改举报
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JiajiaJuBao jiajiaJuBao = jiajiaJuBaoService.selectJiajiaJuBaoById(id);
        mmap.put("jiajiaJuBao", jiajiaJuBao);
        return prefix + "/edit";
    }

    /**
     * 修改保存举报
     */
    @RequiresPermissions("jiajia:jiajiajubao:edit")
    @Log(title = "举报", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JiajiaJuBao jiajiaJuBao)
    {
        return toAjax(jiajiaJuBaoService.updateJiajiaJuBao(jiajiaJuBao));
    }

    /**
     * 删除举报
     */
    @RequiresPermissions("jiajia:jiajiajubao:remove")
    @Log(title = "举报", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jiajiaJuBaoService.deleteJiajiaJuBaoByIds(ids));
    }
}
